package hot_100;

public class 跳跃游戏 {
    public static void main(String[] args) {
        int[] nums = {2,3,1,1,4};
        boolean b = canJump(nums);
        System.out.println(b);
    }

    public static boolean canJump(int[] nums) {
        int n = nums.length;
        int leng = 0;
        int i = 0;
        for (; i <= Math.min(leng, n - 1); i++) {
            leng = Math.max(leng, i + nums[i]);
        }
        if(i>=n)
            return true;
        return false;
    }
}
